/*
 * @Description: 设备管理
 * @Author: Wang ZhongWang
 * @Date: 2022-02-20 10:11:35
 * @LastEditTime: 2022-02-20 10:49:55
 * @LastEditors: Wang ZhongWang
 */

import request from '@/utils/request'

export function getAllDeviceInfo(query){
  var params = JSON.parse(JSON.stringify(query))
  return request({
    url: '/winglinks/link/device/selectAllDeviceInfo',
    method: 'get',
    params: params
  })
}
// -------------------------------------------

/**
 * 分页查询
 * @param query
 */
export function getListPage(query) {
  var params = JSON.parse(JSON.stringify(query))
  return request({
    url: '/iot/device/pageList',
    method: 'post',
    data: params
  })
}

/**
 * 获取详情
 */
export function getDeviceById(query) {
  var params = JSON.parse(JSON.stringify(query))
  return request({
    url: '/iot/device/getById',
    method: 'get',
    params: params
  })
}

/**
 * 获取设备列表对应各个状态的设备数量
 */
export function listStatusCount(query) {
  var params = JSON.parse(JSON.stringify(query))
  return request({
    url: '/iot/device/listStatusCount',
    method: 'get',
    params: params
  })
}

/**
 * 更新产品信息
 * @param query
 */
export function updateDevice(query) {
  var data = JSON.parse(JSON.stringify(query))
  return request({
    url: '/iot/device/updateDevice',
    method: 'post',
    data: data
  })
}
/**
 * 新增产品信息
 * @param query
 */
export function addDevice(query) {
  var data = JSON.parse(JSON.stringify(query))
  return request({
    url: '/iot/device/add',
    method: 'post',
    data: data
  })
}

/**
 * 删除设备
 * @param query
 */
export function removeDevice(query) {
  var params = JSON.parse(JSON.stringify(query))
  return request({
    url: '/iot/device/removeDevice',
    method: 'get',
    params: params
  })
}

// 校验clientId是否存在
export function validationFindOneByClientId(query) {
  var params = JSON.parse(JSON.stringify(query))
  return request({
    url: '/iot/device/validationFindOneByClientId',
    method: 'get',
    params: params
  })
}
// 校验设备标识是否存在
export function validationFindOneByDeviceIdentification(query) {
  var params = JSON.parse(JSON.stringify(query))
  return request({
    url: '/iot/device/validationFindOneByDeviceIdentification',
    method: 'get',
    params: params
  })
}

/**
 * 获取产品列表
 * @param query
 */
export function selectProductList(query) {
  var params = JSON.parse(JSON.stringify(query))
  return request({
    url: '/iot/product/selectList',
    method: 'post',
    data: params
  })
}

/**
 * 获取topic分页
 * @param query
 */
export function selectTopicPageList(query) {
  var params = JSON.parse(JSON.stringify(query))
  return request({
    url: '/iot/deviceTopic/pageList',
    method: 'post',
    data: params
  })
}

export function deviceTypeStatistic(query) {
  return request({
    url: '/iot/device/deviceTypeStatistic',
    method: 'get',
    params: query
  })
}

export function connectStatusStatistic(query) {
  return request({
    url: '/iot/device/connectStatusStatistic',
    method: 'get',
    params: query
  })
}

export function deviceStatusStatistic(query) {
  return request({
    url: '/iot/device/deviceStatusStatistic',
    method: 'get',
    params: query
  })
}

